﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace Alfa.Common.ValidationRules {
	public abstract class ValidationRuleBase : ValidationRule {
		public ValidationRuleBase( ) { }

		public string ErrorMessage { get; set; }

		public ValidationResult ParseError(bool isValid, string errorMessage) {
			if (isValid) {
				return new ValidationResult(true, null);
			} else {
				if (string.IsNullOrEmpty(this.ErrorMessage))
					return new ValidationResult(false, errorMessage);
				else
					return new ValidationResult(false, this.ErrorMessage);
			}
		}

		public abstract override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo);
	}
}